home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18527 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.3 KB

  1. Path: ix.netcom.com!news
  2. From: Bradd W. Szonye <bradds@ix.netcom.com>
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
  4. Subject: RE: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
  5. Date: 20 Apr 1996 16:15:27 GMT
  6. Organization: Netcom
  7. Message-ID: <01bb2ed5.084d0e40$65c2b7c7@Zany.localhost>
  8. References: <JSA.96Feb16135027@organon.com> <829194658snz@tsys.demon.co.uk> <DppsHq.1Ar@world.std.com> <01bb2dcf.e0201620$c6c2b7c7@Zany.localhost> <Dq4vpD.161@world.std.com>
  9. NNTP-Posting-Host: det-mi3-05.ix.netcom.com
  10. X-NETCOM-Date: Sat Apr 20 11:15:27 AM CDT 1996
  11. X-Newsreader: Microsoft Internet News
  12.  
  13.  
  14. On Friday, April 19, 1996, Robert A Duff wrote...
  15. > In article <01bb2dcf.e0201620$c6c2b7c7@Zany.localhost>,
  16. > Bradd W. Szonye  <bradds@ix.netcom.com> wrote:
  17. > >Pardon me if this sounds silly, but...
  18. > >You shouldn't have to rely on the documentation to make up for a lack
  19. of
  20. > >common sense.
  21. > Well, sorry, but it *does* sound pretty silly, to me.  Anybody who's
  22. > been around computer software for a while knows pretty well that
  23. > predicting what software does from some vague notion of "common sense"
  24. > is impossible.
  25. > For example, common sense might tell you that function arguments are
  26. > evaluated from left to right.  Not true in C, not true in Ada, not true
  27. > in C++ (there, I made it relevant to all these newsgroups, in case
  28. > anyone's still listening ;-) ).  These languages all go *against* common
  29. > sense (for obscure efficiency reasons, of course).  In this case, if you
  30. > rely on common sense, instead of reading the language standard, you'll
  31. > get into deep trouble.
  32. > - Bob
  33.  
  34. I don't let documents substitute for common sense. That doesn't mean I
  35. *ignore* the documentation; that would non-sensical too. Part of common
  36. sense is experience. Experience tells you that arguments get pushed (not
  37. evaluated) right-to-left. Experience tells you you can't count on what
  38. order C evaluates function arguments at all. Experience tells you that if
  39. you claim that a buffer is 1000 bytes long, it should be 1000 bytes long,
  40. even if the standard *explicitly* says that it's okay to do otherwise
  41. under certain circumstances.
  42.  
  43. In general, you shouldn't use every nitpicky detail of what is and isn't
  44. legal according to the standard. Not all compilers are conformant, even if
  45. they claim to be. Compiler vendors make mistakes too, and frequently your
  46. only guarantee that a compiler is 100% conformant is the vendor's
  47. assurance that it is.
  48.  
  49. I know programmers who will look up (or have memorized) the operator
  50. precedence rules in C. These programmers will always use the minimal
  51. number of parentheses in an expression because they know the rules
  52. precisely. Not everyone does; maintenance programmers in particular tend
  53. to be junior programmers who don't know all the rules. A maintenance
  54. programmer is likely to "fix" something that looks wrong, even if it
  55. isn't. And a maintenance programmer is likely to misinterpret some subtle
  56. detail of a standard that the original programmer had to look up in the
  57. first place.
  58.  
  59. My personal rule: if you have to look it up to make sure you're absolutely
  60. right, your code may not be maintainable or portable. If you can do it
  61. without looking it up; if it's absolutely as clear as the nose on your
  62. face, then it's okay. For more on this, read "Writing Solid Code" by Steve
  63. Maguire (Microsoft Press).
  64.  
  65.  
  66.